package com.example.demo.service.impl;

import com.example.demo.dao.AreaDao;
import com.example.demo.dao.CityDao;
import com.example.demo.dao.DistrictDao;
import com.example.demo.dao.ProvinceDao;
import com.example.demo.model.AreaEntity;
import com.example.demo.model.CityEntity;
import com.example.demo.model.DistrictEntity;
import com.example.demo.model.ProvinceEntity;
import com.example.demo.service.QueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QueryServiceImpl implements QueryService {

    @Autowired
    private ProvinceDao provinceDao;
    @Autowired
    private CityDao cityDao;
    @Autowired
    private DistrictDao districtDao;
    @Autowired
    private AreaDao areaDao;

    @Override
    public List<ProvinceEntity> getAllProvinces() {
        return provinceDao.getAll();
    }

    @Override
    public List<CityEntity> getCitiesByProvinceAdcode(String adcode) {
        return cityDao.getByPadcode(adcode);
    }

    @Override
    public List<DistrictEntity> getDistrictsByCityAdcode(String adcode) {
        return districtDao.getByPadcode(adcode);
    }

    @Override
    public AreaEntity getAreaByAdcode(String adcode) {
        return areaDao.getByAdcode(adcode);
    }

}
